package com.longrise.android.byjk.plugins.tabfirst.commentdialog;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;

/**
 * Created by sujizhong on 16/8/29.
 */
public class InputBackEditText extends EditText {

    public InputBackEditText(Context context) {
        super(context);
    }

    public InputBackEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public InputBackEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public interface InputBackListener {
        void back(TextView textView);
    }

    private InputBackListener mListener;

    public void setInputBackListener(InputBackListener listener) {
        this.mListener = listener;
    }

    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (mListener != null) {
                mListener.back(this);
            }
        }
        return false;
    }
}

